package hw;
import java.util.ArrayList;
import java.util.List;

//this class calculates the price

public class CargoCompany {

	private String name;
	private double pricePerDistance;
	private double pricePerWeight;
	private double pricePerItem;
	private double price;
	List<String> cities;
	private Map map;


	    public double getPricePerDistance() {
		return pricePerDistance;
	}

	public void setPricePerDistance(double pricePerDistance) {
		this.pricePerDistance = pricePerDistance;
	}

	public double getPricePerWeight() {
		return pricePerWeight;
	}

	public void setPricePerWeight(double pricePerWeight) {
		this.pricePerWeight = pricePerWeight;
	}

	public double getPricePerItem() {
		return pricePerItem;
	}

	public void setPricePerItem(double pricePerItem) {
		this.pricePerItem = pricePerItem;
	}


	public List<String> getCities() {
		return cities;
	}

	public void setCities(List<String> cities) {
		this.cities = cities;
	}
//constructor
		public CargoCompany(String name,Map map,double pricePerDistance, double pricePerWeight, double PricePerItem) {
		  this.name = name;
		  this.cities = new ArrayList<String>();
		  this.pricePerDistance = pricePerDistance;
		  this.pricePerWeight = pricePerWeight;
		  this.pricePerItem = PricePerItem;
		  this.map = map;
	    }
	    
	    public void setName(String name) {
				return;
		}
	    public String getName(){
	    	return this.name;
	    }
	   
//price calculation
  
	public double calculateprice (Shipment shipment){
		double price = 0;
		if (cities.contains(shipment.getCityFrom())){ //to calculate price source city must be available for the shipment
			if(shipment.getWeight() > 0 && shipment.getNumberOfItems() > 0) { // weight and items must have positive values
			price = pricePerDistance* map.getDistance(shipment.getCityFrom(), shipment.getCityTo()) + pricePerWeight*shipment.getWeight() + pricePerItem*shipment.getNumberOfItems();
			}
			
			}else {
			System.out.println("The shipment is not possible for " + CargoCompany.this.name);
		}
		return price;
		
   }
	public boolean isCity(String city){
		return cities.contains(city);
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}
}